package behavior2.visitor;

import java.util.Random;
import java.util.Vector;

public class ObjectStructure {
	private Vector<Element> elements;
	
	public ObjectStructure(){
		elements = new Vector<Element>();
	}
	
	public void action(Visitor vi){
		for(Element e:elements){
			e.accept(vi);
		}
	}
	
	public void add(Element e){
		elements.add(e);
	}
	
	public void createElements(){
		Random rand = new Random();
		for(int i=0;i<10;i++){
			if(rand.nextInt(100)>50){
				this.add(new ConcreteElement1());
			} else {
				this.add(new ConcreteElement2());
			}
		}
	}
}
